package com.lyxy.exception;

import com.lyxy.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName GlobalExceptionHandler
 * @Description TODO
 * 全局异常处理类
 */
@RestControllerAdvice  //@RestControllerAdvice = @ControllerAdvice + @ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)   //捕获所有异常
    public Result handleException(Exception e) {
        e.printStackTrace();
        return Result.error("操作失败,请联系管理员");
    }
}
